package cn.itcast.bos.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.itcast.bos.dao.AreaDao;
import cn.itcast.bos.domain.base.Area;
import cn.itcast.bos.service.AreaService;
@Service
@Transactional
public class AreaServiceImpl implements AreaService {
	//注入Dao
	@Autowired
	private AreaDao areaDao;
	
	@Override
	/**
	 * 导入数据
	 * @return
	 * @throws Exception
	 */
	public void save(List<Area> areaList) {
		//这里我们不需要遍历一个一个添加再添加了，底层帮我们封装好了直接用就可以了
		//<S extends T> List<S> save(Iterable<S> entities);
		areaDao.save(areaList);
	}
	/*
	 * 分页查询
	 * (non-Javadoc)
	 * @see cn.itcast.bos.service.AreaService#findPageDate(org.springframework.data.jpa.domain.Specification, org.springframework.data.domain.Pageable)
	 */
	@Override
	public Page<Area> findPageDate(Specification<Area> specifications, Pageable pageable) {
		
		return areaDao.findAll(specifications,pageable);
	}
	/*添加数据
	 * (non-Javadoc)
	 * @see cn.itcast.bos.service.AreaService#saveArea(cn.itcast.bos.domain.base.Area)
	 */
	@Override
	public void saveArea(Area model) {
		areaDao.save(model);
		
	}
	//查询所有的数据
	@Override
	public List<Area> subArea_findALL() {
		return areaDao.findAll();
	}

}
